{extend name="template/base" /}
{block name="nav"}{/block}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Url::build('createOrUpdate')}">
            <input type="text" class="input-text" value="{$user.sid ?? ''}" placeholder="" name="id" " style="width:0;height:0">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>姓名：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$user.name ?? ''}" placeholder="" name="name" datatype="*" nullmsg="请填写姓名">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">性别：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="radio"  name="gender" value="1" checked="checked" />男
                &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="gender" value="2" />女
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>手机：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$user.mobile ?? ''}" placeholder="" name="mobile" datatype="m" nullmsg="请填写手机号码" errormsg="手机格式错误">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>密码：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$user.password ?? ''}" placeholder="" name="password" datatype="*" errormsg="请填写密码">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        {if $role==1}
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>权限：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$user.role ?? ''}" placeholder="" name="role" datatype="n" errormsg="请填写权限">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        {/if}

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="cancelAction();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__STATIC__/admin/lib/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {
        $("#form").Validform({
            tiptype:2,
            ajaxPost:true,
            showAllError:true,
            callback:function(ret){
                if(ret.code){
                    layer.msg(ret.msg);
                }
                else{
                    layer.msg('操作成功');
                    location.href = history.go(-1);location.reload();
                }
            }
        });
//        window.location.href = "/index/user/show";
    });
    $("input[name='gender'][value={$user.gender ?? 1}]").attr("checked",true);
    function cancelAction(){
        window.location.href = history.go(-1);location.reload();
    }
</script>
{/block}